package swa.group22;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import swa2012.telco.broker.beans.Client;
import swa2012.telco.broker.beans.Message;


public class MessageStore implements iMessageStore {

	private Map<String, Set<Message>> messageContainer;
	
	/**
	 * Method to add a message to the message store.
	 * 
	 * @param message to add
	 */
	@Override
	public void addMessage(Message msg) {
		messageContainer.put(msg.getReceiver().getID(), (Set<Message>) msg);
		
	}

	/**
	 * Method to get messages form the message store.
	 * 
	 * @param client id
	 */
	@Override
	public Collection<Message> getMessages(String id) {
		Collection<Message> messages = messageContainer.get(id);
		messageContainer.remove(id);
		return messages;
		
	}
	
}
